package controller;

import model.Patient;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.PatientService;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
@ResponseBody
@RequestMapping("/patient")
public class PatientController {
    @Resource
    private PatientService service;

    @RequestMapping("/addPatient.do")
    public Map<String,Object> addPatient(Patient patient){
        int n = service.add(patient);
        Map<String,Object> map = new HashMap<>();
        map.put("code","200");
        map.put("msg","");
        map.put("data",n);
        return map;
    }

    @RequestMapping("/checkCard.do")
    public Map<String,Object> checkCard(String card){
        int n = service.checkCard(card);
        Map<String,Object> map = new HashMap<>();
        map.put("code","200");
        map.put("msg","");
        map.put("data",n);
        return map;
    }

    @RequestMapping("/checkMedicare.do")
    public Map<String,Object> checkMedicare(String medicare){
        int n = service.checkMedicare(medicare);
        Map<String,Object> map = new HashMap<>();
        map.put("code","200");
        map.put("msg","");
        map.put("data",n);
        return map;
    }
}
